package com.dkd.sbtz.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.dkd.common.annotation.Log;
import com.dkd.common.core.controller.BaseController;
import com.dkd.common.core.domain.AjaxResult;
import com.dkd.common.enums.BusinessType;
import com.dkd.sbtz.domain.AssetAssessment;
import com.dkd.sbtz.service.IAssetAssessmentService;
import com.dkd.common.utils.poi.ExcelUtil;
import com.dkd.common.core.page.TableDataInfo;

/**
 * 设备评估Controller
 * 
 * @author xzj
 * @date 2025-10-23
 */
@RestController
@RequestMapping("/sbtz/assessment")
public class AssetAssessmentController extends BaseController
{
    @Autowired
    private IAssetAssessmentService assetAssessmentService;

    /**
     * 查询设备评估列表
     */
    @PreAuthorize("@ss.hasPermi('sbtz:assessment:list')")
    @GetMapping("/list")
    public TableDataInfo list(AssetAssessment assetAssessment)
    {
        startPage();
        List<AssetAssessment> list = assetAssessmentService.selectAssetAssessmentList(assetAssessment);
        return getDataTable(list);
    }

    /**
     * 导出设备评估列表
     */
    @PreAuthorize("@ss.hasPermi('sbtz:assessment:export')")
    @Log(title = "设备评估", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AssetAssessment assetAssessment)
    {
        List<AssetAssessment> list = assetAssessmentService.selectAssetAssessmentList(assetAssessment);
        ExcelUtil<AssetAssessment> util = new ExcelUtil<AssetAssessment>(AssetAssessment.class);
        util.exportExcel(response, list, "设备评估数据");
    }

    /**
     * 获取设备评估详细信息
     */
    @PreAuthorize("@ss.hasPermi('sbtz:assessment:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(assetAssessmentService.selectAssetAssessmentById(id));
    }

    /**
     * 新增设备评估
     */
    @PreAuthorize("@ss.hasPermi('sbtz:assessment:add')")
    @Log(title = "设备评估", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AssetAssessment assetAssessment)
    {
        return toAjax(assetAssessmentService.insertAssetAssessment(assetAssessment));
    }

    /**
     * 修改设备评估
     */
    @PreAuthorize("@ss.hasPermi('sbtz:assessment:edit')")
    @Log(title = "设备评估", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AssetAssessment assetAssessment)
    {
        return toAjax(assetAssessmentService.updateAssetAssessment(assetAssessment));
    }

    /**
     * 删除设备评估
     */
    @PreAuthorize("@ss.hasPermi('sbtz:assessment:remove')")
    @Log(title = "设备评估", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(assetAssessmentService.deleteAssetAssessmentByIds(ids));
    }
}
